#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
    while(1){
    printf("Please draw three cards.\n");
    char card1[2],card2[2],card3[2];
    scanf("%2s %2s %2s",card1,card2,card3);
    int a,b,c,s=0;
    switch (card1[0])
    {
    case'J':
    case'Q':
    case'K':
        a=10;
        break;
    case'A':
        {
        if(s+11<=21)
           a = 11;
        else
           a = 1;
        }
        break;
    default:
    a=atoi(card1);
    }s=s+a;
    switch (card2[0])
    {
    case'J':
    case'Q':
    case'K':
        b=10;
    if (a==11&&s+10>21)
        s=s-10;
        break;
    case'A':
        {
        if(s+11<=21)
           b = 11;
        else
           b = 1;
        }
        break;
    default:
    b=atoi(card2);
    }s=s+b;
    switch (card3[0])
    {
    case'J':
    case'Q':
    case'K':
        c=10;
    if (a==11&&s+10>21)
        s=s-10;
    if (b==11&&s+10>21)
        s=s-10;
        break;
    case'A':
        {
        if(s+11<=21)
           c = 11;
        else
           c = 1;
        }
        break;
    default:
    if (a==11&&s+atoi(card3)>21)
        s=s-10;
    if (b==11&&s+atoi(card3)>21)
    c=atoi(card3);
    }s=s+c;
    if (s<=21)
        printf("%d\n",s);
    else
        printf("More than 21 points.\n");
    printf("Do you want to continue ? 1 or 0.\n");
    int d=1;
    scanf("%d",&d);
    if(d==0){
    break;}
    }
}
